package com.atguigu.lease.web.app.service.impl;

import com.atguigu.lease.model.entity.ApartmentInfo;
import com.atguigu.lease.model.entity.FacilityInfo;
import com.atguigu.lease.model.entity.LabelInfo;
import com.atguigu.lease.model.entity.RoomInfo;
import com.atguigu.lease.model.enums.ItemType;
import com.atguigu.lease.web.app.mapper.*;
import com.atguigu.lease.web.app.service.ApartmentInfoService;
import com.atguigu.lease.web.app.vo.apartment.ApartmentDetailVo;
import com.atguigu.lease.web.app.vo.graph.GraphVo;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author liubo
 * @description 针对表【apartment_info(公寓信息表)】的数据库操作Service实现
 * @createDate 2023-07-26 11:12:39
 */
@Service
@RequiredArgsConstructor
public class ApartmentInfoServiceImpl extends ServiceImpl<ApartmentInfoMapper, ApartmentInfo>
        implements ApartmentInfoService {
    private final RoomInfoMapper roomInfoMapper;
    private final GraphInfoMapper graphInfoMapper;
    private final LabelInfoMapper labelInfoMapper;
    private final ApartmentInfoMapper apartmentInfoMapper;
    private final FacilityInfoMapper facilityInfoMapper;
    @Override
    public ApartmentDetailVo getDetailById(Long id) {
        ApartmentDetailVo res=new ApartmentDetailVo();
        BigDecimal minRent= roomInfoMapper.getMinRent(id);
        res.setMinRent(minRent);
        ApartmentInfo apartmentInfo = apartmentInfoMapper.selectById(id);
        List<LabelInfo> labelInfoList = labelInfoMapper.selectListByApartmentId(id);
        //配套列表"
        List<FacilityInfo> facilityInfoList=facilityInfoMapper.getFaciapment(id);
        res.setFacilityInfoList(facilityInfoList);
        List<GraphVo> graphVoList = graphInfoMapper.selectListByItemTypeAndId(ItemType.APARTMENT, id);
        res.setGraphVoList(graphVoList);
        res.setLabelInfoList(labelInfoList);
        System.out.println("begin"+res);
        BeanUtils.copyProperties(apartmentInfo,res);
        System.out.println("begin"+res);
        return res;
    }
}




